package com.foreknow.demo03;


import java.util.Scanner;

public class LianXi3 {
    public static int[] a(int b[]){
        int num =0; //偶数数组的长度
        int r = 0; //偶数下标的值
        for(int i= 0;i<b.length;i++){
            if(b[i]%2==0){
                num+=1;
            }
        }
        int []result = new int [num];
        for (int i= 0;i<b.length;i++){
            if(b[i]%2==0){
                result[r]=b[i];
                r++;
            }
        }
        return result;
    }

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int [] arr= new int [10];
        for(int i=0;i<arr.length;i++){
            System.out.println("请输入10个整数");
            //接受控制台输入
            arr[i] = input.nextInt();
        }
        int [] c = LianXi3.a(arr);
        for(int i=0;i<c.length;i++){
            System.out.println(c[i]);
        }
    }

}
